<!doctype html>
<html>

<head>
	<meta charset="UTF-8">
	<title></title>
	<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
	<link href="../css/mui.min.css" rel="stylesheet" />
	<link rel="stylesheet" type="text/css" href="../css/user.css" />

</head>

<body style="background-color: #F4F4F4;">
	<div class="bottom-bow"></div>
	<div id="user">
		<div class="header">
			<div class="header-title">我的</div>
			<div class="header-desc" @click="openMyDetailClick">
				<img class="header-bg" src="../images/wybr.png" />
				<div class="desc-wapper">
					<div class="name">{{userData.empName}}</div>
					<div class="position">{{userData.orgName}}：{{userData.postName}}</div>
				</div>
				<div class="desc-portrait">
					<img :src="userData.empImg|| 'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1529382604731&di=6e0415e1f41804a3420d09112f0b9f67&imgtype=0&src=http%3A%2F%2Fbpic.588ku.com%2Felement_origin_min_pic%2F01%2F48%2F88%2F2757444507812f6.jpg' "
					    alt="" />
				</div>
			</div>
		</div>
		<div class="list">
			<div class="item" @click="messageClick">
				<div class="item-icon">
					<img src="../images/xiaoxi.png" />
				</div>
				<div class="item-title bottom-underline">

					<span class="title">公告</span>
					<!--<span class="desc">查看新消息</span>-->
					<span class="mui-icon mui-icon-arrowright"></span>
				</div>
			</div>
			<div class="item" @click="ReportMatter">
				<div class="item-icon">
					<img src="../images/s_baoshi.png" />
				</div>
				<div class="item-title bottom-underline">
					<span class="title">报事</span>
					<span class="mui-icon mui-icon-arrowright"></span>
				</div>
			</div>
			<div class="item" @click="settingClick">
				<div class="item-icon">
					<img src="../images/shezhi.png" />
				</div>
				<div class="item-title ">
					<span class="title">设置</span>
					<span class="mui-icon mui-icon-arrowright"></span>
				</div>
			</div>
		</div>
		<div class="list margin-top20" @click="disembark">
			<div class="item">
				<div class="item-icon">
					<img src="../images/tuichu.png" />
				</div>
				<div class="item-title">
					<span class="title">退出登录</span>
				</div>
			</div>
		</div>
	</div>

	<script src="../js/mui.min.js"></script>
	<script src="../js/Width.js" type="text/javascript" charset="utf-8"></script>
	<script src="../js/vue.js"></script>
	<script src="../js/util.js" type="text/javascript" charset="utf-8"></script>
	<script src="https://cdn.bootcss.com/fastclick/1.0.6/fastclick.min.js"></script>
	<script type="text/javascript">
		var user = new Vue({
			el: '#user',
			data: {
				userData: {}
			},
			computed: {
				empImg: function () {
					return this.userDatas.filesPrefix + this.userDatas.filesPath
				}
			},
			methods: {
				messageClick: function () {
					mui.openWindow({
						url: 'NewNotice/index.html',
						id: 'index.html',
						waiting: {
							autoShow: false
						}
					});
				},
				ReportMatter: function () {
					mui.openWindow({
						url: 'ReportMatter.html',
						id: 'ReportMatter.html',
						waiting: {
							autoShow: false
						}
					});
				},
				openMyDetailClick: function () {
					mui.openWindow({
						url: 'my.html',
						id: 'my.html',
						waiting: {
							autoShow: false
						}
					});
				},
				settingClick: function () {
					plus.nativeUI.actionSheet({
						cancel: "取消",
						buttons: [{
								title: "修改密码"
							},
							{
								title: "关于我们"
							},
							{
								title: '意见反馈'
							}
						]
					}, function (e) {
						var htmlUrl
						if (e.index == 1) {
							htmlUrl = 'Setting/AmendPassword.html'
						} else if (e.index == 2) {
							htmlUrl = 'Setting/AboutUs.html'
						} else if (e.index == 3) {
							htmlUrl = 'Setting/feedback.html'
						}
						if (htmlUrl) {
							mui.openWindow({
								url: htmlUrl,
								id: htmlUrl,
								waiting: {
									autoShow: false
								}
							});
						}

					});
				},
				disembark: function () {
					plus.nativeUI.confirm("您要退出登录吗？", function (e) {
						if (e.index == 0) {
							plus.storage.removeItem("stand");
							plus.storage.removeItem("userID");
							setTimeout(function () {
								plus.runtime.restart();
							}, 500)
						}
					});
				}
			}
		})
		window.addEventListener('refresh', function (e) {
			location.reload();
		});

		window.addEventListener('UpEmployeeInfo', function (msg) {
			//自定义方法，刷新数据，不刷新页面
			GetUserDesc()
		})

		mui.init({

		})

		mui.plusReady(function () {
			if (!mui.os.android) {
				FastClick.attach(document.body);
			}
			GetUserDesc() // 调用个人信息请求接口方法
			var self = plus.webview.currentWebview();
			self.addEventListener('show', function () {
				GetUserDesc() // 调用个人信息请求接口方法
			})
		})

		function GetUserDesc() {
			var userID = plus.storage.getItem("userID")
			if (userID) {
				mui.post(httpUrl.testUrl + '/api/Users/GetEmployeeInfo', {
					userID: userID
				}, function (res) {
					if (res.code == 1001) {

						res.data.empImg = res.data.filesPrefix + res.data.filesPath
						user.userData = res.data

						plus.storage.setItem('empID', res.data.empID)
						console.log('empID:' + res.data.empID)
					} else {
						mui.toast('资源请求错误！')
					}
				})
			}
		}
	</script>
</body>

</html>
